﻿//创建时间: 2010-10-11
//创建作者: 李 城
//功能说明: 字符替换 管理
//最后修改: 2010-10-11
using System;
using System.Collections.Generic;

using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using TRPOP.Common;
using TRPOP.CMS.Web.UI;


using TRPOP.CMS.Business;
using TRPOP.CMS.Model;

namespace TRPOP.CMS.Web.Admin
{
    public partial class WordReplace_list : BaseAdmin
    {
        #region 当前页面权限验证
        protected override void SubPageInit()
        {
            base.m_SubPagePermission = Plugin.PermissionKeys.PermissionEnum.SystemManage_KeysReplace;
        }
        #endregion

        
        #region 页面变量
        protected string m_strTitle = "文字替换管理";
        protected int m_cid = 0;
        protected string m_linkStr = "";
        WordReplaceManage m_WordReplaceManage = new WordReplaceManage();
        #endregion

        #region 页面事件
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                InitRequestViewState("cid");
                LoadBase();
                BindData();
            }
            else
            {
                LoadBase();
            }
        }
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            string Ids = RequestHelper.RequestString("delid");
            if (Ids.Length == 0)
            {
                Alert("请先选中要删除的信息");
                BindData();
                return;
            }
            SubmitAlertDelete(m_WordReplaceManage.DeleteInfoByIds(Ids));
            BindData();
        }
        protected void lbtnDelete_Click(object sender, EventArgs e)
        {
            LinkButton lbtn = (LinkButton)sender;
            int intDelId = int.Parse(lbtn.CommandArgument);
            SubmitAlertDelete(m_WordReplaceManage.DeleteInfoById(intDelId));
            base.SaveLog(Plugin.LogKeys.OperObject.TemplateOper, Plugin.LogKeys.OperResult.DelSubmit);
            BindData();
        }
        protected void PageChanged(object sender, EventArgs e)
        {
            BindData();
        }
        #endregion

        #region 页面方法
        protected void BindData()
        {
            int recordCount = 0;
            int.TryParse(GetRequestViewState("cid"), out m_cid);
            if (m_cid > 0)
            {
                rptList.DataSource = m_WordReplaceManage.GetListByPager(UC_Pager.CurrentPage, UC_Pager.PageSize, " and Type="+m_cid.ToString()+"  ", " AddTime desc ", out recordCount);
            }
            else
                rptList.DataSource = m_WordReplaceManage.GetListByPager(UC_Pager.CurrentPage, UC_Pager.PageSize, "", " AddTime desc ", out recordCount);
            rptList.DataBind();
            UC_Pager.RecordCount = recordCount;
        }

        protected void LoadBase()
        {
            int.TryParse(GetRequestViewState("cid"), out m_cid);
            foreach (KeyValuePair<int, string> TemoInfo in PageAssist.GetAllWordReplaceType(SystemInfoHelper.getSystemInfo().AdminFolderName))
            {
                if (TemoInfo.Key == m_cid)
                {
                    m_strTitle = TemoInfo.Value + "管理";
                }
                //m_linkStr += string.Format("<a href=\"WordReplace_list.aspx?cid={0}\" >{1}</a>{2}", TemoInfo.Key.ToString(), TemoInfo.Value, Utils.Spaces(1));
            }
        }
        #endregion
    }
}
